<!DOCTYPE html>
<div id="console"></div>
<script>
if (window.testRunner) {
      testRunner.dumpAsText();
      testRunner.waitUntilDone();
}

var iframe = document.body.appendChild(document.createElement("iframe"));
var o = undefined;

function test() {
    var win = iframe.contentWindow;
    function recurse() {
        try { recurse(); } catch(e) {}
        try { win.location.href; } catch(e) {
            o = e;
        }
    }
    recurse();
    if (o.constructor.constructor("return location.hostname")() == "127.0.0.1") {
        document.getElementById("console").innerText = "PASS: non-cross-site exception thrown.";
    } else {
        document.getElementById("console").innerText = "FAIL: cross-site exception thrown.";
    }
    if (window.testRunner) {
        testRunner.notifyDone();
    }
}

function waitForLoaded() {
    try { frames[0].a; } catch(e) {
        clearInterval(interval);
        test();
    }
}

var interval = setInterval(waitForLoaded, 1);
iframe.src = "http://localhost:8000/resources/dummy.html";
</script>
